﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SmartCity.BasicData.Api.Application.Commond.Area;
using SmartCity.BasicData.Common;

namespace SmartCity.BasicData.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class AreaController : ControllerBase
    {
        private readonly IMediator mediator;

        public AreaController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 获取所有区域的树形数据结构
        /// </summary>
        /// <returns></returns>
        //[HttpGet]
        //public  Task<ApiResult<IList<AreaDTO>>> GetAreaTrees() { 
        //    GetAreaCommand getAreaCommand = new GetAreaCommand();
        //    return  mediator.Send(getAreaCommand) ;
        //}
        [HttpGet]
        public Task<ApiResult<List<AreaTreeDTO>>> GetAreaTree() {
            return mediator.Send(new GetAreaTreeCommond());
        }
    }
}
